number_of_integers = int(input())
array = list(map(int, input().split(' ')))
convert_to_set = list(set(array))
convert_to_set.sort()
if 0 < len(convert_to_set) < 3:
print('YES')
elif len(convert_to_set) == 3:
if convert_to_set[1] - convert_to_set[0] == convert_to_set[2] - convert_to_set[1]:
print('YES')
else:
print('NO')
else:
print('NO')
#include <bits/stdc++.h>
#define loop(n) for(int i = 1; i <= n; i++)
#define rloop(n) for(int i = n; i >= 1; i--)
#define loop0(n) for(int i = 0; i < n; i++)
#define rloop0(n) for(int i = n-1; i >= 0; i--)
#define iloop(s,n,step) for(int i = s; i <= n; i+=step)
#define jloop(s,n,step) for(int j = s; j <= n; j+=step)
#define loopit(x) for(auto it = x.begin(); it!= x.end(); it++)
#define all(x) x.begin(),x.end()
using namespace std;
void fast(){
ios_base::sync_with_stdio(false);
cin.tie(0);
}
int main()
{
fast();
int tc = 1;
//cin >> tc;
while(tc--){
long long n,x;
cin >> n;
vector<long long> v;
set<long long> s;
loop(n){
cin >> x;
if(s.find(x)==s.end()){
v.push_back(x);
s.insert(x);
}
}
if(v.size()>3){
cout << "NO";
}
else if(v.size()==1 || v.size()==2){
cout << "YES";
}
else if(v.size()==3){
sort(all(v));
x=v[0]+v[2];
if(2*v[1]==x){
cout << "YES";
}
else{
cout << "NO";
}
}
}
return 0;
}
199A - Hexadecimal's theorem | 519C - A and B and Team Training |
631A - Interview | 961B - Lecture Sleep |
522A - Reposts | 1166D - Cute Sequences |
1176A - Divide it | 1527A - And Then There Were K |
1618E - Singers' Tour | 1560B - Who's Opposite |
182B - Vasya's Calendar | 934A - A Compatible Pair |
1618F - Reverse | 1684C - Column Swapping |
57C - Array | 1713D - Tournament Countdown |
33A - What is for dinner | 810A - Straight A |
1433C - Dominant Piranha | 633A - Ebony and Ivory |
1196A - Three Piles of Candies | 299A - Ksusha and Array |
448B - Suffix Structures | 1092B - Teams Forming |
1166C - A Tale of Two Lands | 544B - Sea and Islands |
152B - Steps | 1174D - Ehab and the Expected XOR Problem |
1511A - Review Site | 1316A - Grade Allocation |